<template>
    <div style="width: 100%;height: 100%">
        <Button icon="ios-search" type="primary" @click="todoCalculate">自动计算</Button>
        <div id="contentDiv">
            <vxe-table border
                       auto-resize
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       highlight-hover-row
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :data="tableData">
                <vxe-table-column field="name" title="人员姓名" align="center"/>
                <vxe-table-column field="ssbi0003" title="分类救助上浮类别" align="center"/>
                <vxe-table-column field="ssbi0006" title="上浮比例" align="center" :formatter="renderSsbi0006"/>
                <vxe-table-column field="ssbi0005" title="分类救助金额" align="center"/>
                <vxe-table-column field="ssbi0008" title="高龄补贴金额" align="center"/>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <div id="buttonDiv">
            <Button @click="prevStep" style="margin-right: 10px"> 上一步</Button>
            <Button type="primary" @click="nextStep">下一步</Button>
        </div>
    </div>
</template>

<script>
    import {getAction, postAction} from '@/api/request'
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import '@/views/common/css/common.css';

    export default {
        name: "application2",
        mixins: [CommonMixin],
        data() {
            return {
                url: {
                    list: "/api/ac/subsistence/ss17011Service/page",
                    calculate: "/api/ac/subsistence/ss17011Service/createAndCalculate",
                },
                Loading: false,
                familyInfo: {},
                queryParam: {},
                columns: [],
            }
        },
        methods: {

            prevStep() {
                this.$emit('prevStep');
            },
            nextStep() {
                this.$emit('nextStep');
            },
            getFamilyInfor() {
                this.familyInfo = this.$parent.familyInfo;
                this.doCalculate();
            },
            doCalculate() {
                var that = this;
                postAction(that.url.calculate, {ss12001Id: this.familyInfo.ss12001Id}).then((res) => {
                    if (res.data.errcode == 0) {
                        that.queryParam.ssbi0002 = that.familyInfo.ss17001Id;
                        that.loadData();
                    } else {
                        that.$Message.error(res.data.errmsg);
                    }
                }).finally(() => {
                    that.Loading = false;
                });
            },
            todoCalculate() {
                var that = this;
                this.$Modal.confirm({
                    title: '自动计算将会删除家庭现有分类救助信息，是否确认操作？',
                    onOk: () => {
                        that.doCalculate();
                    }
                })
            }
        },
        created() {
            this.Loading = true;
            this.getFamilyInfor();
        }
    }
</script>

<style scoped>

</style>
